package com.tencent.mlvb.apilive.ui;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.tencent.mlvb.apilive.R;
import com.tencent.mlvb.apilive.bean.LivePlanBean;
import com.tencent.mlvb.apilive.ui.adpter.BaseRecyclerAdapter;
import com.tencent.mlvb.apilive.ui.adpter.BaseRecyclerHolder;

public class TaskAdapter extends BaseRecyclerAdapter<LivePlanBean>{
    private ItemOnClickListener itemOnClickListener;
    public TaskAdapter(Context context, int layoutRes) {
        super(context, layoutRes);
    }

    @Override
    public void convert(BaseRecyclerHolder holder, int position) {
        ImageView imageView = (ImageView)holder.getView(R.id.img_select);
        TextView tvContent = (TextView)holder.getView(R.id.tv_content);
        tvContent.setText(items.get(position).getName());
        if (items.get(position).isSelect()){
            imageView.setImageResource(R.mipmap.radio_checked_five);
        }else {
            imageView.setImageResource(R.mipmap.radio_unchecked_five);
        }
        holder.getView(R.id.layout_item).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (itemOnClickListener != null){
                    itemOnClickListener.itemOnClick(position);
                }
            }
        });
    }
    public void setItemOnClickListener(ItemOnClickListener listener){
        itemOnClickListener = listener;
    }
    public interface ItemOnClickListener{
        void itemOnClick(int position);
    }
}
